package com.example.works;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Work06Dialog extends AppCompatActivity implements View.OnClickListener {

    private AlertDialog.Builder builder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_work06_dialog);
        Button btn_01 = findViewById(R.id.btn_01);
        btn_01.setOnClickListener(this);
        builder = new AlertDialog.Builder(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_01:
                builder.create();
                builder.setTitle("我是对话框的标题");
                builder.setMessage("我是对话框的内容");
                builder.show();
                break;
            default:
                break;
        }
    }
}